package tresp.utils;

import java.io.Serializable;

import tresp.bthreads.BThreadType;


/**
 * <b>BThreadVote</b>
 * 
 * @author <font color="blue">Maxim Kirilov</font>
 *
 */
public class BThreadVote implements Comparable<BThreadVote>{


    /**Vote type*/
    private BThreadType voteType;
    
    /**Vote weight*/
    private double weight;
    
    /**Vote parameter*/
    private double parameter;
    
    /**A message recipient name*/
    private String recipientName;
    
    /**A message*/
    private Serializable message;
    
    
    public BThreadVote(BThreadType voteType, double weight, double parameter){
	this.voteType = voteType;
	this.weight = weight;
	this.parameter = parameter;
    }
    
    
    public BThreadType getVoteType() {
        return voteType;
    }


    public double getWeight() {
        return weight;
    }


    public double getParameter() {
        return parameter;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }

    @Override
    public boolean equals(Object other){
	
	if (other instanceof BThreadVote){
	    return ((BThreadVote) other).voteType == this.voteType;
	}
	
	return false;
	
    }
    
    @Override
    public int hashCode(){
	return this.voteType.hashCode();
    }
    
    
    @Override
    public int compareTo(BThreadVote other) {
	
	if (weight < other.getWeight()){
	    return 1;
	}
	if (weight > other.getWeight()){
	    return -1;
	}
	
	return 0;
    }


    public String getRecipientName() {
        return recipientName;
    }


    public void setRecipientName(String recipientName) {
        this.recipientName = recipientName;
    }


    public Serializable getMessage() {
        return message;
    }


    public void setMessage(Serializable message) {
        this.message = message;
    }
}
